// page/component/person/person.js
Page({

  data: {
    userInfo: null,
    vipState: null,
    timer: null,
    userID: null,
    order: null
  },

  onShow () {
    console.log('App Show')
    console.log(getApp().globalData);
    console.log('4646');
    let that = this;
    const userInfo = getApp().globalData.userInfo;
    this.setData({
      userInfo: userInfo
    });
    wx.getStorage({
      key: 'userID',
      success(res) {
        that.setData({
          userID: res.data
        }) 
      }
    });
    let userId = this.data.userID;
    if (userId == null) {
      userId = getApp().globalData.userID
    } 
    wx.request({
      url: 'https://localhost:80/admins/query',
      data: {
        adminId: userId
      },
      header: {
        'content-type': 'application/json'
      },
      method: 'post',
      success (res) { 
        console.log(res.data);
        that.setData({
          vipState: res.data.adminsState,
          timer: res.data.adminDate,
          // order: 2
          order: res.data.adminRole
        })
        console.log(that.data.order);
      }
    });
  },

  tiaozhuan (e) {
    let num = e.currentTarget.dataset.num;
    let numUrl = '../myorders/myorders?num=' + num;  
    wx.navigateTo({
      url: numUrl
    }); 
  },
  
  address () {
    wx.navigateTo({
      url: '../alladdress/alladdress'
    })
  },

  helpcenter () {
    wx.navigateTo({
      url: '../helpcenter/helpcenter'
    })
  },

  setting () {
    wx.navigateTo({
      url: '../setting/setting'
    })
  },

  credit () {
    // wx.navigateTo({
    //   url: '../credit/credit'
    // })
    wx.showModal({
      title: '提示',
      content: '该服务暂未开通，敬请期待',
      text:'center',
      complete() {}
    });
  },

  discount () {
    // wx.navigateTo({
    //   url: '../discount/discount'
    // })
    wx.showModal({
      title: '提示',
      content: '该服务暂未开通，敬请期待',
      text:'center',
      complete() {}
    });
  },

  vipcenter () {
    wx.navigateTo({
      url: '../vipcenter/vipcenter?data=' + this.data.timer
    })
  },

  boardcast () {
    wx.navigateTo({
      url: '../boardcast/boardcast'
    })
  }
})